import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

/**
 * 个性化配置service
 * @date: 2019-12-15
 */
import request from 'utils/request';
import { CPAAS_PLATFORM } from 'utils/config';
import { getCurrentOrganizationId } from 'utils/utils'; // const mockapi = '/api/cpfm';

export function queryCode() {
  return _queryCode.apply(this, arguments);
}

function _queryCode() {
  _queryCode = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
    var params,
        _args = arguments;
    return _regeneratorRuntime.wrap(function _callee$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            params = _args.length > 0 && _args[0] !== undefined ? _args[0] : {};
            return _context.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/lovs/value"), {
              query: params
            }));

          case 2:
          case "end":
            return _context.stop();
        }
      }
    }, _callee);
  }));
  return _queryCode.apply(this, arguments);
}

export function queryModule() {
  return _queryModule.apply(this, arguments);
}

function _queryModule() {
  _queryModule = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
    var params,
        _args2 = arguments;
    return _regeneratorRuntime.wrap(function _callee2$(_context2) {
      while (1) {
        switch (_context2.prev = _context2.next) {
          case 0:
            params = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : {};
            return _context2.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/list/model"), {
              query: params
            }));

          case 2:
          case "end":
            return _context2.stop();
        }
      }
    }, _callee2);
  }));
  return _queryModule.apply(this, arguments);
}

export function queryTree() {
  return _queryTree.apply(this, arguments);
}

function _queryTree() {
  _queryTree = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3() {
    var params,
        _args3 = arguments;
    return _regeneratorRuntime.wrap(function _callee3$(_context3) {
      while (1) {
        switch (_context3.prev = _context3.next) {
          case 0:
            params = _args3.length > 0 && _args3[0] !== undefined ? _args3[0] : {};
            return _context3.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/menu-tree"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context3.stop();
        }
      }
    }, _callee3);
  }));
  return _queryTree.apply(this, arguments);
}

export function queryGroup() {
  return _queryGroup.apply(this, arguments);
}

function _queryGroup() {
  _queryGroup = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4() {
    var params,
        _args4 = arguments;
    return _regeneratorRuntime.wrap(function _callee4$(_context4) {
      while (1) {
        switch (_context4.prev = _context4.next) {
          case 0:
            params = _args4.length > 0 && _args4[0] !== undefined ? _args4[0] : {};
            return _context4.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/groupUnits"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context4.stop();
        }
      }
    }, _callee4);
  }));
  return _queryGroup.apply(this, arguments);
}

export function queryUnitDetails() {
  return _queryUnitDetails.apply(this, arguments);
}

function _queryUnitDetails() {
  _queryUnitDetails = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5() {
    var params,
        _args5 = arguments;
    return _regeneratorRuntime.wrap(function _callee5$(_context5) {
      while (1) {
        switch (_context5.prev = _context5.next) {
          case 0:
            params = _args5.length > 0 && _args5[0] !== undefined ? _args5[0] : {};
            return _context5.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/details"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context5.stop();
        }
      }
    }, _callee5);
  }));
  return _queryUnitDetails.apply(this, arguments);
}

export function saveFieldIndividual() {
  return _saveFieldIndividual.apply(this, arguments);
}

function _saveFieldIndividual() {
  _saveFieldIndividual = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6() {
    var params,
        _args6 = arguments;
    return _regeneratorRuntime.wrap(function _callee6$(_context6) {
      while (1) {
        switch (_context6.prev = _context6.next) {
          case 0:
            params = _args6.length > 0 && _args6[0] !== undefined ? _args6[0] : {};
            return _context6.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/save"), {
              body: params,
              method: 'POST'
            }));

          case 2:
          case "end":
            return _context6.stop();
        }
      }
    }, _callee6);
  }));
  return _saveFieldIndividual.apply(this, arguments);
}

export function queryFieldMapping() {
  return _queryFieldMapping.apply(this, arguments);
}

function _queryFieldMapping() {
  _queryFieldMapping = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7() {
    var params,
        _args7 = arguments;
    return _regeneratorRuntime.wrap(function _callee7$(_context7) {
      while (1) {
        switch (_context7.prev = _context7.next) {
          case 0:
            params = _args7.length > 0 && _args7[0] !== undefined ? _args7[0] : {};
            return _context7.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/mapping/details"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context7.stop();
        }
      }
    }, _callee7);
  }));
  return _queryFieldMapping.apply(this, arguments);
}

export function queryConditions() {
  return _queryConditions.apply(this, arguments);
}

function _queryConditions() {
  _queryConditions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
    var params,
        _args8 = arguments;
    return _regeneratorRuntime.wrap(function _callee8$(_context8) {
      while (1) {
        switch (_context8.prev = _context8.next) {
          case 0:
            params = _args8.length > 0 && _args8[0] !== undefined ? _args8[0] : {};
            return _context8.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/condition"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context8.stop();
        }
      }
    }, _callee8);
  }));
  return _queryConditions.apply(this, arguments);
}

export function queryRelatedUnits() {
  return _queryRelatedUnits.apply(this, arguments);
}

function _queryRelatedUnits() {
  _queryRelatedUnits = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
    var params,
        _args9 = arguments;
    return _regeneratorRuntime.wrap(function _callee9$(_context9) {
      while (1) {
        switch (_context9.prev = _context9.next) {
          case 0:
            params = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {};
            return _context9.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/unit/related"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context9.stop();
        }
      }
    }, _callee9);
  }));
  return _queryRelatedUnits.apply(this, arguments);
}

export function deleteFieldIndividual() {
  return _deleteFieldIndividual.apply(this, arguments);
}

function _deleteFieldIndividual() {
  _deleteFieldIndividual = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10() {
    var params,
        _args10 = arguments;
    return _regeneratorRuntime.wrap(function _callee10$(_context10) {
      while (1) {
        switch (_context10.prev = _context10.next) {
          case 0:
            params = _args10.length > 0 && _args10[0] !== undefined ? _args10[0] : {};
            return _context10.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/delete"), {
              query: params,
              method: 'DELETE'
            }));

          case 2:
          case "end":
            return _context10.stop();
        }
      }
    }, _callee10);
  }));
  return _deleteFieldIndividual.apply(this, arguments);
}

export function saveHeaderIndividual() {
  return _saveHeaderIndividual.apply(this, arguments);
}

function _saveHeaderIndividual() {
  _saveHeaderIndividual = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11() {
    var params,
        _args11 = arguments;
    return _regeneratorRuntime.wrap(function _callee11$(_context11) {
      while (1) {
        switch (_context11.prev = _context11.next) {
          case 0:
            params = _args11.length > 0 && _args11[0] !== undefined ? _args11[0] : {};
            return _context11.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/save-header"), {
              body: params,
              method: 'POST'
            }));

          case 2:
          case "end":
            return _context11.stop();
        }
      }
    }, _callee11);
  }));
  return _saveHeaderIndividual.apply(this, arguments);
}

export function querySelfValidator() {
  return _querySelfValidator.apply(this, arguments);
}

function _querySelfValidator() {
  _querySelfValidator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
    var params,
        _args12 = arguments;
    return _regeneratorRuntime.wrap(function _callee12$(_context12) {
      while (1) {
        switch (_context12.prev = _context12.next) {
          case 0:
            params = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : {};
            return _context12.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/condition-valid"), {
              query: params,
              method: 'GET'
            }));

          case 2:
          case "end":
            return _context12.stop();
        }
      }
    }, _callee12);
  }));
  return _querySelfValidator.apply(this, arguments);
}

export function saveSelfValidator() {
  return _saveSelfValidator.apply(this, arguments);
}

function _saveSelfValidator() {
  _saveSelfValidator = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13() {
    var params,
        _args13 = arguments;
    return _regeneratorRuntime.wrap(function _callee13$(_context13) {
      while (1) {
        switch (_context13.prev = _context13.next) {
          case 0:
            params = _args13.length > 0 && _args13[0] !== undefined ? _args13[0] : {};
            return _context13.abrupt("return", request("".concat(CPAAS_PLATFORM, "/v1/").concat(getCurrentOrganizationId(), "/unit-config/condition-valid"), {
              body: params,
              method: 'POST'
            }));

          case 2:
          case "end":
            return _context13.stop();
        }
      }
    }, _callee13);
  }));
  return _saveSelfValidator.apply(this, arguments);
}